home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_061 / microemacs / estruct.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  18KB  |  490 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.8
  3.  
  4.             written by Dave G. Conroy
  5.             modified by Steve Wilhite, George Jones
  6.             greatly modified by Daniel Lawrence
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE        /* don't use their definitions...use ours    */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    CPM
  16. #undef    CPM
  17. #endif
  18. #ifdef    AMIGA
  19. #undef    AMIGA
  20. #endif
  21.  
  22. /*    Version definition            */
  23.  
  24. #define    VERSION    "3.8b"
  25.  
  26. /*    Machine/OS definitions            */
  27.  
  28. #define AMIGA   1                       /* AmigaDOS            */
  29. #define ST520   0                       /* ST520, TOS                   */
  30. #define MSDOS   0                       /* MS-DOS                       */
  31. #define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
  32. #define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  33. #define    USG    0            /* UNIX system V        */
  34. #define VMS     0                       /* VAX/VMS                      */
  35. #define CPM     0                       /* CP/M-86                      */
  36. #define    FINDER    0            /* Macintosh OS            */
  37.  
  38. /*    Compiler definitions            */
  39. #define MWC86   0    /* marc williams compiler */
  40. #define    LATTICE    0    /* Lattice 2.14 thruough 3.0 compilers */
  41. #define    AZTEC    1    /* Aztec C 3.20e */
  42. #define    MSC    0    /* MicroSoft C compile version 3 */
  43. #define MEGAMAX 0    /* Megamax C compiler */
  44.  
  45. /*    Profiling options    */
  46. #define    APROF    0    /* turn Aztec C profiling on? */
  47. #define    NBUCK    100    /* number of buckets to profile */
  48. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  49. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  50.  
  51. /*   Special keyboard definitions            */
  52.  
  53. #define WANGPC    0        /* WangPC - mostly escape sequences     */
  54.  
  55. /*    Terminal Output definitions        */
  56.  
  57. #define ANSI    1            /* ansi escape sequences    */
  58. #define    HP150    0            /* HP150 screen driver        */
  59. #define    HP110    0            /* HP110 screen driver        */
  60. #define    VMSVT    0            /* various VMS terminal entries    */
  61. #define VT52    0                       /* VT52 terminal (Zenith).      */
  62. #define VT100   0                       /* Handle VT100 style keypad.   */
  63. #define LK201   0                       /* Handle LK201 style keypad.   */
  64. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  65. #define TERMCAP 0                       /* Use TERMCAP                  */
  66. #define    IBMPC    0            /* IBM-PC CGA/MONO driver    */
  67. #define    EGA    0            /* EGA IBM-PC specific driver    */
  68. #define    DG10    0            /* Data General system/10    */
  69. #define    TIPC    0            /* TI Profesional PC driver    */
  70. #define    MAC    0            /* Macintosh            */
  71. #define    ATARI    0            /* Atari 520/1040ST screen    */
  72.  
  73. /*    Configuration options    */
  74.  
  75. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  76. #define    NFWORD    1    /* forward word jumps to beginning of word    */
  77. #define    CLRMSG    0    /* space clears the message line with no insert    */
  78. #define    ACMODE    1    /* auto CMODE on .C and .H files        */
  79. #define    CFENCE    1    /* fench matching in CMODE            */
  80. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  81. #define DEBUGM    1    /* Global SPELL mode triggers macro debugging    */
  82. #define    VISMAC    0    /* update display during keyboard macros    */
  83. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  84.  
  85. #define    REVSTA    1    /* Status line appears in reverse video        */
  86. #define    COLOR    1    /* color commands and windows            */
  87.  
  88. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  89. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  90. #define    WORDPRO    1    /* Advanced word processing features        */
  91. #define    FLABEL    0    /* function key label code            */
  92. #define    APROP    1    /* Add code for Apropos command            */
  93. #define    CRYPT    1    /* file encryption enabled?            */
  94. #define MAGIC    1    /* include regular expression matching?        */
  95.  
  96. #define ASCII    1    /* always using ASCII char sequences for now    */
  97. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  98.  
  99. /*    System dependant library redefinitions, structures and includes    */
  100.  
  101. /*  Megamax C defines short to be 1 byte and int to be 2 bytes */
  102. #if    MEGAMAX & ST520
  103. #define SHORT int
  104. #else
  105. #define SHORT short
  106. #endif
  107.  
  108. #if    AZTEC
  109. #undef    fputc
  110. #undef    fgetc
  111. #define    fputc    aputc
  112. #define    fgetc    agetc
  113. #define    int86    sysint
  114. #define    intdos(a, b)    sysint(33, a, b)
  115. #define    inp    inportb
  116.  
  117. struct XREG {
  118.     int ax,bx,cx,dx,si,di;
  119. };
  120.  
  121. struct HREG {
  122.     char al,ah,bl,bh,cl,ch,dl,dh;
  123. };
  124.  
  125. union REGS {
  126.     struct XREG x;
  127.     struct HREG h;
  128. };
  129. #endif
  130.  
  131. #if    MSDOS & MWC86
  132. #include    <dos.h>
  133. #define    int86(a, b, c)    intcall(b, c, a)
  134. #define    inp    in
  135.  
  136. struct XREG {
  137.     int ax,bx,cx,dx,si,di,ds,es,flags;
  138. };
  139.  
  140. struct HREG {
  141.     char al,ah,bl,bh,cl,ch,dl,dh;
  142.     int ds,es,flags;
  143. };
  144.  
  145. union REGS {
  146.     struct XREG x;
  147.     struct HREG h;
  148. };
  149. #endif
  150.  
  151. #if    MSDOS & MSC
  152. #include    <dos.h>
  153. #define    movmem(a, b, c)        memcpy(b, a, c)
  154. #endif
  155.  
  156. #if    MSDOS & LATTICE
  157. #undef    CPM
  158. #undef    LATTICE
  159. #include    <dos.h>
  160. #undef    CPM
  161. #endif
  162.  
  163. #if    VMS
  164. #define    unlink(a)    delete(a)
  165. #endif
  166.  
  167. /*    define memory mapped flag    */
  168.  
  169. #define    MEMMAP    0
  170.  
  171. #if    IBMPC
  172. #undef    MEMMAP
  173. #define    MEMMAP    1
  174. #endif
  175.  
  176. #if    IBMMONO
  177. #undef    MEMMAP
  178. #define    MEMMAP    1
  179. #endif
  180.  
  181. #if    EGA
  182. #undef    MEMMAP
  183. #define    MEMMAP    1
  184. #endif
  185.  
  186. /*    internal constants    */
  187.  
  188. #define    NBINDS    256            /* max # of bound keys        */
  189. #define NFILEN  80                      /* # of bytes, file name        */
  190. #define NBUFN   16                      /* # of bytes, buffer name      */
  191. #define NLINE   256                     /* # of bytes, line             */
  192. #define    NSTRING    128            /* # of bytes, string buffers    */
  193. #define NKBDM   256                     /* # of strokes, keyboard macro */
  194. #define NPAT    128                     /* # of bytes, pattern          */
  195. #define HUGE    1000                    /* Huge number                  */
  196. #define    NLOCKS    100            /* max # of file locks active    */
  197. #define    NCOLORS    8            /* number of supported colors    */
  198. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  199. #define    NBLOCK    16            /* line block chunk size    */
  200. #define    NVSIZE    10            /* max #chars in a var name    */
  201.  
  202. #if    0
  203. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  204. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  205. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  206. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  207. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  208. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  209. #endif
  210.  
  211. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  212. #define META    0x0200                  /* Meta flag, or'ed in          */
  213. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  214. #define    SPEC    0x0800            /* special key (function keys)    */
  215.  
  216. #define FALSE   0                       /* False, no, bad, etc.         */
  217. #define TRUE    1                       /* True, yes, good, etc.        */
  218. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  219. #define    FAILED    3            /* not-quite fatal false return    */
  220. #define    RET    4            /* a return from buffer        */
  221. #define    GOLINE    5            /* exit flagging a GOTO        */
  222.  
  223. #define    STOP    0            /* keyboard macro not in use    */
  224. #define    PLAY    1            /*          playing    */
  225. #define    RECORD    2            /*          recording    */
  226.  
  227. #define    FORWARD    0            /* forward direction        */
  228. #define REVERSE    1            /* backwards direction        */
  229.  
  230. #define FIOSUC  0                       /* File I/O, success.           */
  231. #define FIOFNF  1                       /* File I/O, file not found.    */
  232. #define FIOEOF  2                       /* File I/O, end of file.       */
  233. #define FIOERR  3                       /* File I/O, error.             */
  234. #define    FIOLNG    4            /* line longer than allowed len    */
  235. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  236.  
  237. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  238. #define CFKILL  0x0002                  /* Last command was a kill      */
  239.  
  240. #define    BELL    0x07            /* a bell character        */
  241. #define    TAB    0x09            /* a tab character        */
  242.  
  243. #if    V7 | USG | BSD
  244. #define    PATHCHR    ':'
  245. #else
  246. #define    PATHCHR    ';'
  247. #endif
  248.  
  249. #define    INTWIDTH    sizeof(int)/3 + 2
  250.  
  251. /*    Macro argument token types                    */
  252.  
  253. #define    TKNUL    0            /* end-of-string        */
  254. #define    TKARG    1            /* interactive argument        */
  255. #define    TKBUF    2            /* buffer argument        */
  256. #define    TKVAR    3            /* user variables        */
  257. #define    TKENV    4            /* environment variables    */
  258. #define    TKFUN    5            /* function....            */
  259. #define    TKDIR    6            /* directive            */
  260. #define    TKLBL    7            /* line label            */
  261. #define    TKLIT    8            /* numeric literal        */
  262. #define    TKSTR    9            /* quoted string literal    */
  263. #define    TKCMD    10            /* command name            */
  264.  
  265. /*    Internal defined functions                    */
  266.  
  267. /* DIFCASE represents the integer difference between upper
  268.    and lower case letters.  It is an xor-able value, which is
  269.    fortunate, since the relative positions of upper to lower
  270.    case letters is the opposite of ascii in ebcdic.
  271. */
  272.  
  273. #ifdef    islower
  274. #undef    islower
  275. #endif
  276.  
  277. #if    ASCII
  278.  
  279. #define    DIFCASE        0x20
  280. #define isletter(c)    (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
  281. #define islower(c)    (('a' <= c && 'z' >= c))
  282. #endif
  283.  
  284. #if    EBCDIC
  285.  
  286. #define    DIFCASE        0x40
  287. #define isletter(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
  288. #define islower(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
  289. #endif
  290.  
  291. /*    Dynamic RAM tracking and reporting redefinitions    */
  292.  
  293. #if    RAMSIZE
  294. #define    malloc    allocate
  295. #define    free    release
  296. #endif
  297.  
  298. /*
  299.  * There is a window structure allocated for every active display window. The
  300.  * windows are kept in a big list, in top to bottom screen order, with the
  301.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  302.  * The flag field contains some bits that are set by commands to guide
  303.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  304.  * the full blown redisplay is just too expensive to run for every input
  305.  * character.
  306.  */
  307. typedef struct  WINDOW {
  308.         struct  WINDOW *w_wndp;         /* Next window                  */
  309.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  310.         struct  LINE *w_linep;          /* Top line in the window       */
  311.         struct  LINE *w_dotp;           /* Line containing "."          */
  312.         short   w_doto;                 /* Byte offset for "."          */
  313.         struct  LINE *w_markp;          /* Line containing "mark"       */
  314.         short   w_marko;                /* Byte offset for "mark"       */
  315.         char    w_toprow;               /* Origin 0 top row of window   */
  316.         char    w_ntrows;               /* # of rows of text in window  */
  317.         char    w_force;                /* If NZ, forcing row.          */
  318.         char    w_flag;                 /* Flags.                       */
  319. #if    COLOR
  320.     char    w_fcolor;        /* current forground color    */
  321.     char    w_bcolor;        /* current background color    */
  322. #endif
  323. }       WINDOW;
  324.  
  325. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  326. #define WFMOVE  0x02                    /* Movement from line to line   */
  327. #define WFEDIT  0x04                    /* Editing within a line        */
  328. #define WFHARD  0x08                    /* Better to a full display     */
  329. #define WFMODE  0x10                    /* Update mode line.            */
  330. #define    WFCOLR    0x20            /* Needs a color change        */
  331.  
  332. /*
  333.  * Text is kept in buffers. A buffer header, described below, exists for every
  334.  * buffer in the system. The buffers are kept in a big list, so that commands
  335.  * that search for a buffer by name can find the buffer header. There is a
  336.  * safe store for the dot and mark in the header, but this is only valid if
  337.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  338.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  339.  * the header line in "b_linep".
  340.  *     Buffers may be "Inactive" which means the files accosiated with them
  341.  * have not been read in yet. These get read in at "use buffer" time.
  342.  */
  343. typedef struct  BUFFER {
  344.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  345.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  346.         short   b_doto;                 /* Offset of "." in above LINE  */
  347.         struct  LINE *b_markp;          /* The same as the above two,   */
  348.         short   b_marko;                /* but for the "mark"           */
  349.         struct  LINE *b_linep;          /* Link to the header LINE      */
  350.     char    b_active;        /* window activated flag    */
  351.         char    b_nwnd;                 /* Count of windows on buffer   */
  352.         char    b_flag;                 /* Flags                        */
  353.     char    b_mode;            /* editor mode of this buffer    */
  354.         char    b_fname[NFILEN];        /* File name                    */
  355.         char    b_bname[NBUFN];         /* Buffer name                  */
  356. #if    CRYPT
  357.     char    b_key[NPAT];        /* current encrypted key    */
  358. #endif
  359. }       BUFFER;
  360.  
  361. #define BFINVS  0x01                    /* Internal invisable buffer    */
  362. #define BFCHG   0x02                    /* Changed since last write     */
  363.  
  364. /*    mode flags    */
  365. #define    NUMMODES    8        /* # of defined modes        */
  366.  
  367. #define    MDWRAP    0x0001            /* word wrap            */
  368. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  369. #define    MDSPELL    0x0004            /* spell error parcing        */
  370. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  371. #define    MDVIEW    0x0010            /* read-only buffer        */
  372. #define MDOVER    0x0020            /* overwrite mode        */
  373. #define MDMAGIC    0x0040            /* regular expresions in search */
  374. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  375.  
  376. /*
  377.  * The starting position of a region, and the size of the region in
  378.  * characters, is kept in a region structure.  Used by the region commands.
  379.  */
  380. typedef struct  {
  381.         struct  LINE *r_linep;          /* Origin LINE address.         */
  382.         short   r_offset;               /* Origin LINE offset.          */
  383.         long    r_size;                 /* Length in characters.        */
  384. }       REGION;
  385.  
  386. /*
  387.  * All text is kept in circularly linked lists of "LINE" structures. These
  388.  * begin at the header line (which is the blank line beyond the end of the
  389.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  390.  * number of bytes in the line (the "used" size), the size of the text array,
  391.  * and the text. The end of line is not stored as a byte; it's implied. Future
  392.  * additions will include update hints, and a list of marks into the line.
  393.  */
  394. typedef struct  LINE {
  395.         struct  LINE *l_fp;             /* Link to the next line        */
  396.         struct  LINE *l_bp;             /* Link to the previous line    */
  397.         short   l_size;                 /* Allocated size               */
  398.         short   l_used;                 /* Used size                    */
  399.         char    l_text[1];              /* A bunch of characters.       */
  400. }       LINE;
  401.  
  402. #define lforw(lp)       ((lp)->l_fp)
  403. #define lback(lp)       ((lp)->l_bp)
  404. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  405. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  406. #define llength(lp)     ((lp)->l_used)
  407.  
  408. /*
  409.  * The editor communicates with the display using a high level interface. A
  410.  * "TERM" structure holds useful variables, and indirect pointers to routines
  411.  * that do useful operations. The low level get and put routines are here too.
  412.  * This lets a terminal, in addition to having non standard commands, have
  413.  * funny get and put character code too. The calls might get changed to
  414.  * "termp->t_field" style in the future, to make it possible to run more than
  415.  * one terminal type.
  416.  */
  417. typedef struct  {
  418.     short    t_mrow;            /* max number of rows allowable */
  419.         short   t_nrow;                 /* current number of rows used  */
  420.         short   t_mcol;                 /* max Number of columns.       */
  421.         short   t_ncol;                 /* current Number of columns.   */
  422.     short    t_margin;        /* min margin for extended lines*/
  423.     short    t_scrsiz;        /* size of scroll region "    */
  424.     int    t_pause;        /* # times thru update to pause */
  425.         int     (*t_open)();            /* Open terminal at the start.  */
  426.         int     (*t_close)();           /* Close terminal at end.       */
  427.     int    (*t_kopen)();        /* Open keyboard        */
  428.     int    (*t_kclose)();        /* close keyboard        */
  429.         int     (*t_getchar)();         /* Get character from keyboard. */
  430.         int     (*t_putchar)();         /* Put character to display.    */
  431.         int     (*t_flush)();           /* Flush output buffers.        */
  432.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  433.         int     (*t_eeol)();            /* Erase to end of line.        */
  434.         int     (*t_eeop)();            /* Erase to end of page.        */
  435.         int     (*t_beep)();            /* Beep.                        */
  436.     int    (*t_rev)();        /* set reverse video state    */
  437.     int    (*t_rez)();        /* change screen resolution    */
  438. #if    COLOR
  439.     int    (*t_setfor)();        /* set forground color        */
  440.     int    (*t_setback)();        /* set background color        */
  441. #endif
  442. }       TERM;
  443.  
  444. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  445.                         dependant place later)    */
  446.  
  447. #define    TTopen        (*term.t_open)
  448. #define    TTclose        (*term.t_close)
  449. #define    TTkopen        (*term.t_kopen)
  450. #define    TTkclose    (*term.t_kclose)
  451. #define    TTgetc        (*term.t_getchar)
  452. #define    TTputc        (*term.t_putchar)
  453. #define    TTflush        (*term.t_flush)
  454. #define    TTmove        (*term.t_move)
  455. #define    TTeeol        (*term.t_eeol)
  456. #define    TTeeop        (*term.t_eeop)
  457. #define    TTbeep        (*term.t_beep)
  458. #define    TTrev        (*term.t_rev)
  459. #define    TTrez        (*term.t_rez)
  460. #if    COLOR
  461. #define    TTforg        (*term.t_setfor)
  462. #define    TTbacg        (*term.t_setback)
  463. #endif
  464.  
  465. /*    structure for the table of initial key bindings        */
  466.  
  467. typedef struct  {
  468.         short   k_code;                 /* Key code                     */
  469.         int     (*k_fp)();              /* Routine to handle it         */
  470. }       KEYTAB;
  471.  
  472. /*    structure for the name binding table        */
  473.  
  474. typedef struct {
  475.     char *n_name;        /* name of function key */
  476.     int (*n_func)();    /* function name is bound to */
  477. }    NBIND;
  478.  
  479. /*    The editor holds deleted text chunks in the KILL buffer. The
  480.     kill buffer is logically a stream of ascii characters, however
  481.     due to its unpredicatable size, it gets implemented as a linked
  482.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  483.     was taken up by the keycode structure)            */
  484.  
  485. typedef    struct KILL {
  486.     struct KILL *d_next;    /* link to next chunk, NULL if last */
  487.     char d_chunk[KBLOCK];    /* deleted text */
  488. } KILL;
  489.  
  490.